package A1_4;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

// Customer 类
class Customer {
    private String name;  // 姓名
    private String contact;  // 联系电话
    private String deliveryAddress;  // 邮寄地址
    private boolean active;  // 是否激活状态

    public Customer(String name, String contact, String deliveryAddress, boolean active) {
        this.name = name;
        this.contact = contact;
        this.deliveryAddress = deliveryAddress;
        this.active = active;
    }

    // Getters and Setters
}

// OrderStatus 枚举
enum OrderStatus {
    CREATE, PAID, SHIPPING, DELIVERED, CANCEL
}

// Order 类
class Order {
    private Date createDate;  // 创建日期
    private OrderStatus status;  // 订单状态
    private Customer customer;  // 所属客户
    private List<OrderDetail> orderDetails;  // 订单详情
    private Payment payment;  // 支付方式

    public Order(Date createDate, Customer customer) {
        this.createDate = createDate;
        this.customer = customer;
        this.status = OrderStatus.CREATE;  // 默认状态为CREATE
        this.orderDetails = new ArrayList<>();
    }

    public void addOrderDetail(OrderDetail orderDetail) {
        orderDetails.add(orderDetail);
    }

    public void setPayment(Payment payment) {
        this.payment = payment;
    }

    // Getters and Setters
}

// OrderDetail 类
class OrderDetail {
    private int quantity;  // 数量
    private Product product;  // 商品项

    public OrderDetail(int quantity, Product product) {
        this.quantity = quantity;
        this.product = product;
    }

    public double calculateSubTotal() {
        return product.getPriceForQuantity(quantity);
    }

    public double calculateWeight() {
        return product.getWeight() * quantity;
    }

    // Getters and Setters
}

// Product 类
class Product {
    private String title;  // 名称
    private double weight;  // 重量
    private String description;  // 描述
    private double price;  // 单价

    public Product(String title, double weight, String description, double price) {
        this.title = title;
        this.weight = weight;
        this.description = description;
        this.price = price;
    }

    public double getPriceForQuantity(int quantity) {
        return price * quantity;
    }

    public double getWeight() {
        return weight;
    }

    // Getters and Setters
}

// Payment 类
abstract class Payment {
    protected double amount;  // 金额

    public Payment(double amount) {
        this.amount = amount;
    }

    // Getters and Setters
}

// Credit 类
class Credit extends Payment {
    private String number;  // 卡号
    private String type;  // 类型
    private Date expireDate;  // 过期日期

    public Credit(double amount, String number, String type, Date expireDate) {
        super(amount);
        this.number = number;
        this.type = type;
        this.expireDate = expireDate;
    }

    // Getters and Setters
}

// Cash 类
class Cash extends Payment {
    private double cashTendered;  // 支付金额

    public Cash(double amount, double cashTendered) {
        super(amount);
        this.cashTendered = cashTendered;
    }

    // Getters and Setters
}

// WireTransfer 类
class WireTransfer extends Payment {
    private String bankID;  // 银行ID
    private String bankName;  // 银行名称

    public WireTransfer(double amount, String bankID, String bankName) {
        super(amount);
        this.bankID = bankID;
        this.bankName = bankName;
    }

    // Getters and Setters
}

// AliPay 类
class AliPay extends Payment {
    private String number;  // 卡号

    public AliPay(double amount, String number) {
        super(amount);
        this.number = number;
    }

    // Getters and Setters
}

// WeixinPay 类
class WeixinPay extends Payment {
    private String number;  // 卡号

    public WeixinPay(double amount, String number) {
        super(amount);
        this.number = number;
    }

    // Getters and Setters
}